package com.heima.feigns.fallback;

import com.heima.feigns.ArticleFeign;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @package com.heima.feigns.fallback
 * @Date 2022/2/27
 * @project heima-leadnews
 */
@Component
@Slf4j
public class ArticleFeignFallback implements FallbackFactory<ArticleFeign> {
    @Override
    public ArticleFeign create(Throwable throwable) {

        return new ArticleFeign() {
            @Override
            public ResponseResult<ApAuthor> insertWmUser(ApAuthor apAuthor) {
                log.error("参数，，，{}",apAuthor);
                log.error("作者信息保存方法失败 {}",throwable.getMessage());
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);

            }

            @Override
            public ResponseResult<ApAuthor> selectById(Integer id) {
                log.error("参数，，，{}",id);
                log.error("作者信息查询方法失败 {}",throwable.getMessage());
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
            }

            @Override
            public ResponseResult<ApArticle> findOne(Long id) {
                log.error("参数，，，{}",id);
                log.error("文章信息查询方法失败 {}",throwable.getMessage());
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);

            }
        };
    }
}
